package com.example.pageradapterdemo.adapter;

import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.pageradapterdemo.R;
import com.example.pageradapterdemo.model.News;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class NewsAdapter extends BaseQuickAdapter<News, BaseViewHolder> {
    public NewsAdapter(int layoutResId) {
        super(layoutResId);
        addChildClickViewIds(R.id.tv_focus);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, News news) {
        if (news.getImgList() != null && news.getImgList().size() > 0) {
            String imgUrl = news.getImgList().get(0);
            ImageView iv = holder.getView(R.id.iv);
            Glide.with(getContext()).load(imgUrl).into(iv);
        }
        holder.setText(R.id.tv_title,news.getTitle());

    }
}
